package com.jem.quotemgr.controller;





import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
//import com.jem.quotemgr.model.Employee;
import com.jem.quotemgr.model.QuoteManager;
import com.jem.quotemgr.util.ApplicationSecurityManager;
import com.jem.quotemgr.util.TimexJmxBean;


public class QuoteListController implements Controller
{
    private QuoteManager quoteManager;
    private ApplicationSecurityManager applicationSecurityManager;
    public static final String MAP_KEY = "quotes";
    private String successView;
    private TimexJmxBean timexJmxBean;

 
    public ModelAndView handleRequest(
            HttpServletRequest request,
            HttpServletResponse response) throws Exception
    {
       // Employee employee = (Employee) applicationSecurityManager
       //         .getEmployee(request);
        List quotes = quoteManager.getQuotes();
        
        //this causes null pointer exception
        //timexJmxBean.setTimesheetsFetched(timexJmxBean.getTimesheetsFetched()
         //       + quotes.size());
        return new ModelAndView(getSuccessView(), MAP_KEY, quotes);
    }

    public QuoteManager getQuoteManager()
    {
        return quoteManager;
    }

    public void setQuoteManager(QuoteManager quoteManager)
    {
        this.quoteManager = quoteManager;
    }

    public ApplicationSecurityManager getApplicationSecurityManager()
    {
        return applicationSecurityManager;
    }

    public void setApplicationSecurityManager(
            ApplicationSecurityManager applicationSecurityManager)
    {
        this.applicationSecurityManager = applicationSecurityManager;
    }

    public String getSuccessView()
    {
        return successView;
    }

    public void setSuccessView(String successView)
    {
        this.successView = successView;
    }

    public TimexJmxBean getTimexJmxBean()
    {
        return timexJmxBean;
    }

    public void setTimexJmxBean(TimexJmxBean timexJmxBean)
    {
        this.timexJmxBean = timexJmxBean;
    }
}